﻿// -----------------------------------------------------------------------
// <copyright file="PersonConverter.cs" company="Microsoft">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

using System.Windows.Data;
using Kinban.ViewModels;

namespace Kinban
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public class PersonConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            MainViewModel viewModel = parameter as MainViewModel;

            var user = viewModel.TfsViewModel.Users.FirstOrDefault(x => string.Compare(x.TfsName, value.ToString(), true) == 0);
            if (user != null)
            {
                return user.PictureUrl;
            }
            else
            {
                return null;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
